import { loc, obj_str, cline, uDb } from 'sui';

const reload_prop = (hDone, hcmd, mod, cur) => {
    uDb(hDone, `file/get/${mod}`,
        {
            "line": cline(),
            "sn": obj_str(cur, "sn"),
        },
        r => {
            const attr = r["attr"];
            hcmd(attr);
        },
        e => hcmd(null));
};

const update_prop = (umd, mod, v, cur, setMain, hcmd) => {
    umd.startWait();

    uDb(null, `file/md/${mod}`,
        {
            line: cline(),
            sn: obj_str(cur, "sn"),
            v: {attr: v},
        },
        r => hcmd(),
        e => umd.setErr(loc("l_232")), true);
};

export {update_prop, reload_prop};
